//
//  QMAJSPluginEngine.h
//  MiniAppSDK
//
//  Created by enigmaliang on 2019/6/2.
//

#import <Foundation/Foundation.h>
#import "MAJSExecutorProtocol.h"

@class MABaseApplication;
@class MAWebView;

NS_ASSUME_NONNULL_BEGIN

@interface QMAJSPluginEngine : NSObject

@property (nonatomic, weak, readonly) MABaseApplication* application;

- (instancetype)initWithApplication:(MABaseApplication *)app;

// TODO: 这两个方法需要删除 当前MAMusicJSPlugin和MAAudioPlayer里面使用到了
- (dispatch_queue_t)currentMiniAppJSQueue;

- (BOOL)isCurrentMiniAppJSQueue;

- (NSSet<Class> *)pluginClass;

- (nullable NSSet<Class> *)preloadPluginClass;

- (NSString *)handleNativeRequest:(NSString *)eventName
                           params:(NSDictionary *)params
                          context:(id<MAJSExecutorProtocol>)context
                       callbackID:(NSInteger)callbackID;

@end

OBJC_EXTERN NSString * const QMA_Delegate_Not_Implemented;
OBJC_EXTERN NSString * const QMA_API_Cancel;
OBJC_EXTERN NSString * const QMA_API_Should_Invoke_In_OpenDataContext;

#define API_IMP(EventName) \
- (NSString *)__qma_api__##EventName:(NSString *) __attribute__((annotate("oclint:suppress[unused method parameter]"))) eventName \
                              params:(NSDictionary *) __attribute__((annotate("oclint:suppress[unused method parameter]"))) params \
                             context:(id<MAJSExecutorProtocol>) __attribute__((annotate("oclint:suppress[unused method parameter]"))) context \
                          callbackID:(NSInteger) __attribute__((annotate("oclint:suppress[unused method parameter]"))) callbackID

@interface QMABaseJSPlugin : NSObject

@property (nonatomic, weak) QMAJSPluginEngine *engine;

- (instancetype)initWithEngine:(QMAJSPluginEngine *)engine;

- (MAWebView * __nullable)webViewWithContext:(id<MAJSExecutorProtocol>)context;

@end

NS_ASSUME_NONNULL_END
